home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 042a / swags_z.zip / WIN-OS2.SWG < prev   
Text File  |  1993-05-28  |  10KB  |  1 lines

  1. SWAGOLX.EXE (c) 1993 GDSOFT  ALL RIGHTS RESERVED 00004         WINDOWS & OS2 STUFF                                               1      05-28-9314:10ALL                      SWAG SUPPORT TEAM        DETCWIN.PAS              IMPORT              13          { GREG ESTABROOKS }ππProgram Win3XInf;      { Simple Detection routines For Windows 3.X    }π                       { Last Updated March 3/93, Greg Estabrooks     }πUsesπ  Crt,π  Dos;ππVarπ  Regs : Registers;    { to hold register info }ππFunction Win3X : Boolean;π{ Routine to determine if Windows is currently running }πbeginπ  Regs.AX := $4680;    { Win 3.x Standard check }π  Intr($2F, Regs);     { Call Int 2F }π  if Regs.AX <> 0 then { if AX = 0 Win in Real mode }π  begin                { else check For enhanced mode }π    Regs.AX := $1600;  { Win 3.x Enhanced check }π    Intr($2F, Regs);   { Call Int 2F }π    if Regs.AL in [$00,$80,$01,$FF] then { Check returned value }π      Win3X := False   { Nope not installed }π    elseπ      Win3X := True;   { Ya it is }π  endπ  elseπ    Win3X := True;     { Return True }πend;πππFunction WinVer :Word;π{  Returns a Word containing the version of Win Running }π{  Should only be used after checking For Win installed }π{  Or value returned will be meaningless                }πbeginπ  Regs.AX := $1600;    {  Enhanced mode check }π  Intr($2F, Regs);     {  Call Int 2F         }π  WinVer := Regs.AX;   {  Return proper value }πend;πππbeginπ  ClrScr;π  if Win3X thenπ  beginπ    Writeln('Windows is Running! ');    { Display version }π    Writeln('Version Running is : ', Lo(WinVer), '.', Hi(WinVer));π  endπ  elseπ    Writeln('Windows is not Running!');πend.π                                                                                                                             2      05-28-9314:10ALL                      SWAG SUPPORT TEAM        OS2CHECK.PAS             IMPORT              34          {πAuthor : GREGORY P. SMITHππ> Is there any way to detect OS/2 (in a Dos box) sessions and Windowsπ> Sessions? I'd like to throw in support For these multitaskers so I canπ> run an idlekey Program.ππActual code is always the best example For me..  Look at this Unit (and useπit, I think you'll like it).  Check With someone else if you want toπspecifically detect winslows.  This Unit will, however, give up time to anyπmultitasker.π}ππ(* Public Domain Unit by Gregory P. Smith, No Rights Reserved *)π(* ...  This also means no guarantees  ... *)ππUnit OS_Test; { DESQview, OS/2, & 386 v86 machine Interfaces }ππ{$X+,S-,R-,F-,O-,D-,G-} { extended syntax, nothing else }ππInterfaceππConstπ  In_DV  : Boolean = False; { are we in DESQview? }π  In_VM  : Boolean = False; { are we in a 386+ virtual machine? }π  In_OS2 : Boolean = False; { are we in OS/2? }ππFunction  OS2_GetVersion: Word; { Get OS/2 version # }πFunction  DV_GetVersion: Word; { update In_DV and get version # }πFunction  DV_Get_Video_Buffer(vseg:Word): Word; { get the alt video buffer }πProcedure DV_Pause; { give up time slice }πProcedure MT_Pause; Inline($cd/$28); { give up time in most multitaskers }πProcedure KillTime; { Release time in any situation }πProcedure DV_begin_Critical; { don't slice away }π  Inline($b8/$1b/$10/$cd/$15);πProcedure DV_end_Critical; { allow slicing again }π  Inline($b8/$1c/$10/$cd/$15);πProcedure DV_Sound(freq,dur:Integer); { Create a Sound in the Bkg }ππImplementationππFunction OS2_GetVersion: Word; Assembler;πAsmπ  MOV    AH, 30h  { Dos Get Version Call }π  INT    21h      { AL = major version * 10, AH = minor version }π  MOV    BH, AH   { save minor version }π  xor    AH, AHπ  MOV    CL, 10π  div    CL       { divide by 10 to get the major version }π  MOV    AH, BH   { restore minor version }π  XCHG   AH, AL   { AH = major, AL = minor }πend;ππFunction DV_GetVersion: Word; Assembler;πAsmπ  MOV    CX,'DE'     { CX+DX to 'DESQ' (invalid date) }π  MOV    DX,'SQ'π  MOV    AX,02B01H   { Dos' set date funct. }π  INT    21H         { call Dos }π  CMP    AL,0FFH     { Was it invalid? }π  JE     @No_dv      { yep, no dv }π  MOV    AX,BX       { AH=major AL=minor }π  MOV    In_DV,1     { Set In_DV flag }π  JMP    @DvGv_x     { other routines }π @No_dv:π  xor    AX,AX       { Return 0 or no DV }π @DvGv_x:πend; { DV_GetVersion }ππFunction DV_Get_Video_Buffer(vseg:Word): Word; Assembler;πAsm                      { Modified by Scott Samet April 1992 }π  CALL   DV_GetVersion   { Returns AX=0 if not in DV }π  MOV    ES,vseg         { Put current segment into ES }π  TEST   AX,AX           { In DV? }π  JZ     @DVGVB_X        { Jump if not }π  MOV    AH,0FEH         { DV's get video buffer Function }π  INT    10H             { Returns ES:DI of alt buffer }π @DVGVB_X:π  MOV    AX,ES           { Return video buffer }πend; { DV_Get_Video_Buffer }ππProcedure DV_Pause;πbeginπ  if In_DV thenπ  Asmπ    MOV AX, 1000h    { pause Function }π    INT 15hπ  end;πend; { DV_Pause }ππProcedure KillTime;πbeginπ  if In_VM thenπ  Asmπ    MOV AX, 1680h    { give up VM time slice }π    INT 2Fhπ  endπ  elseπ  if In_DV thenπ  Asmπ    MOV AX, 1000h    { DV pause call }π    INT 15hπ  endπ  elseπ    MT_Pause;      { Dos Idle call }πend;ππ(* Procedure DV_begin_Critical; Assembler;πAsmπ  MOV AX,$101B       { DV begin critical Function }π  INT 15hπend; { DV_begin_Critical }ππProcedure DV_end_Critical; Assembler;πAsmπ  MOV AX,$101C       { DV end critical Function }π  INT 15hπend; { DV_end_Critical }  *)ππProcedure DV_Sound(freq,dur:Integer); Assembler; { Sound a tone }πAsmπ  MOV   AX,1019Hπ  MOV   BX,freq  { frequency above 20 Hz }π  MOV   CX,dur   { duration in clock ticks }π  INT   15Hπend;ππ{ ** -- initalization -- ** }ππbeginπ  DV_GetVersion; { discard answer.  Just update In_DV }π  Asmπ    MOV AX, 1680hπ    INT 2Fh          { Gives up time slice in most 386+ virtual machines }π    not AL           { AL = 00h if supported, remains 80h if not }π    MOV CL, 7π    SHR AL, CL       { move bit 7 to bit 0 For a Boolean }π    MOV In_VM, AL    { update the flag }π  end;π  In_OS2 := (OS2_GetVersion >= $0100); { version 1.0 or greater }πend.ππ                                                                             3      05-28-9314:10ALL                      SWAG SUPPORT TEAM        WINCHECK.PAS             IMPORT              6           {π>How can I check from my Dos Program that Windows are running inπ>the background?π}ππUnit Chk4Win;ππInterfaceππTypeπ  Win3ModeType = (NoWin, RealStd, Enhanced);ππFunction CheckForWin3 : Win3ModeType;ππImplementationππFunction CheckForWin3 : Win3ModeType;  Assembler;πAsmπ  mov    ax,1600hπ  int    2Fhπ  cmp    al,1π  jbe    @@CheckRealStdπ  cmp    al,80hπ  jae    @@CheckRealStdπ  mov    al,2π  jmp    @@ExitPointπ@@CheckRealStd:π  mov    ax,4680hπ  int    2Fhπ  or     ax,axπ  jnz    @@notWinπ  mov    al,1π  jmp    @@ExitPointπ@@notWin:π  xor    al,alπ@@ExitPoint:πend;ππend.π                                                           4      05-28-9314:10ALL                      SWAG SUPPORT TEAM        WINICONS.PAS             IMPORT              24          {π I am writing a Dos based Program in Turbo Pascal 6.0 that Uses aπ GUI Interface. My problem is that I would like to be able to importπ Windows or OS/2 icons to use instead of making my own. Does anyoneπ know the File Format For either of these Files or better yet haveπ source code For displaying them. Any help would be greatly appreciated.ππThe following code is a Unit I wrote to handle Windows icon Files. Iπdon't have the code yet For OS/2 icon Files, although I believe they areπquite similar. As Far as displaying the icons, just pass a Pointerπto the icon to your Graphics routines and let them decode and displayπthe structures. You should also be able to use a subset of theπstructures to decode icons embedded in Windows .EXE Files.ππAt offset $24 in the "new executable" header For Windows and OS/2 .EXEπFiles is a Word Variable that specifies an additional offset to theπresource table.π}ππUnit WinIcons;ππ(********************************)Interface(*********************************)ππTypeπ  tBMPInfoHdr = Recordπ    vHdrSize,                 (* Always 40 For Windows icons *)π    vPixelWidth,π    vPixelHeight   : LongInt;π    vColorPlanes,             (* Should always be 1 *)π    vBitCount      : Word;π    vCompression,π    vImageSize,π    vXPelsPerMeter,π    vYPelsPerMeter,π    vClrUsed,π    vClrImportant  : LongInt;π  end;ππ  tWinIconColor = Recordπ    vBlue,π    vGreen,π    vRed,π    vUnused : Byte;π  end;ππ  tRGBTable = Array[0..15] of tWinIconColor;ππ  txorMask = Array[0..511] of Byte;ππ  tandMask = Array[0..127] of Byte;ππ  tWinIcon = Record                (* The icon itself *)π    vBMPInfoHdr : tBMPInfoHdr;π    vRGBTable   : tRGBTable;π    vxorMask    : txorMask;π    vandMask    : tandMask;π  end;ππ  tWinIconDirEntry = Record        (* Icon File directory entry.  *)π    vIconWidth,                    (* 1 For each icon in the File *)π    vIconHeight,π    vColorCount,π    vReserved    : Byte;π    vPlanes,π    vBitCount    : Word;π    vBytesInRes,π    vImageoffset : LongInt;π  end;ππ  (* The following two Arrays have to be sized at run-time as they can  *)π  (* hold up to 65,535 entries. The actual number of entries is set by  *)π  (* vIdCount. When reading an icon File, read in the vIdCount Variable *)π  (* and then use GetMem to allocate the correct amount of heap.        *)ππ  tDirListPtr = ^tDirList;π  tDirList    = Array[1..1] of tWinIconDirEntry;ππ  tIconListPtr = ^tIconList;π  tIconList    = Array[1..1] of tWinIcon;ππ  tWinIconFileRec = Recordπ    vIdReserved,π    vIdType,π    vIdCount     : Word;π    vDirList     : tDirListPtr;π    vIconList    : tIconListPtr;π  end;πππ  tWinIconFile = File of tWinIconFileRec;ππVarπ  vWinIconFile : tWinIconFile; (* Hook to access icon Files *)ππ(******************************)Implementation(******************************)ππend.π